#include <iostream>
#define N 100

using namespace std;

int cart_prod(int array_a[], int array_b[], int cart[][2], int elements_a, int elements_b){
int i, j, row=0;
for (i=0;i<elements_a;i++){
    for(j=0;j<elements_b;j++){
        cart[row][0]=array_a[i];
        cart[row][1]=array_b[j];
        ++row;}
    }
return row;
}


void readintVector_A(int array_a[], int elements_a){
for (int i=0; i<elements_a; i++){
	cout<<"a["<<i<<"]=";
	cin>>array_a[i];
	cout<<"\n";}
}

void readintVector_B(int array_b[], int elements_b){
for (int i=0; i<elements_b; i++){
	cout<<"a["<<i<<"]=";
	cin>>array_b[i];
	cout<<"\n";}
}


int main(){
int j;
int array_a[N];
int array_b[N];
int cart[N][2];
int elements_a;
int elements_b;
int column;

cout<<"Type the number of elements you want in the array A: ";
cin>>elements_a;
readintVector_A(array_a, elements_a);

cout<<"Type the number of elements you want in array B: ";
cin>> elements_b;
readintVector_B(array_b, elements_b);

cout<<"The original array A is ";
for(int i=0; i<elements_a; i++){
	cout<<array_a[i]<<" ";}
cout<<endl;

cout<<"The original array B is ";
for(int i=0; i<elements_b; i++){
	cout<<array_b[i]<<" ";}
cout<<endl;

column=cart_prod( array_a, array_b, cart, elements_a,  elements_b);
cout<<"The cartezian product between A and B is: "<<endl;
for(j=0;j<column;j++){
		cout<<"("<<cart[j][0]<<","<<cart[j][1]<<") ";
	cout<<"\n";
}

return 0;
}
